def bubble_sort(arr):
    n = len(arr)
    for i in range(n):
        for j in range(0, n - i - 1):
            if arr[j] > arr[j + 1]:
                arr[j], arr[j + 1] = arr[j + 1], arr[j]
                print('每次迭代的中间数据',i,j)
                

def search():
    pass


def binary_search(arr, target):
    left, right = 0, len(arr) - 1
    while left <= right:
        mid = (left + right) // 2
        if arr[mid] == target:
            return mid
        elif arr[mid] < target:
            left = mid + 1
        else:
            right = mid - 1
    return -1

# 示例用法
if __name__ == "__main__":
    nums = [64, 34, 25, 12, 22, 11, 90]
    bubble_sort(nums)
    print("排序后的数组:", nums)
    index = binary_search(nums, 25)
    print("元素25的索引:", index)